using ChikovMF.Application.Features.Tags.CreateTag;
using Microsoft.EntityFrameworkCore;

namespace ChikovMF.Tests.Tags.Commands;

public class CreateTagTest : TestCommandBase
{
    [Fact]
    public async Task CreateTagTest_Success()
    {
        var handler = new CreateTagCommandHandler(_context);
        var command = new CreateTagCommand
        {
            Name = "CreteTagName",
        };

        var tagId = await handler.Handle(
            command,
            CancellationToken.None
        );

        Assert.NotNull(
            await _context.Tags.FirstOrDefaultAsync(tag =>
                tag.TagId == tagId && tag.Name == command.Name));
    }
}